package myJs.detailInfo

import japgolly.scalajs.react.ScalaFnComponent
import japgolly.scalajs.react.util.EffectCatsEffect._
import japgolly.scalajs.react.vdom.all._
import myJs.Implicits._
import myJs.api.Api
import myJs.myPkg.Hooks._
import myJs.tool.Tool
import shared.pojo.Browse._

/** Created by yz on 28/11/2023
  */
object AssemblyCp {

  case class Props(id: String)

  val Component = ScalaFnComponent[Props] { props =>
    val (basicData, setBasicData) = useState(AssemblyInfo())

    object FTool {

      def refreshBasicData = {
        Api.browse.getAssembly(props.id).flatMap { response =>
          setBasicData(response)
        }
      }

    }

    useEffect(
      {
        FTool.refreshBasicData
      },
      List(props.id)
    )

    div(
     AssemblySummaryCp(basicData=basicData),
     AssemblyGenomeCp(basicData=basicData),
    )

  }

  def apply(id: String) = {
    Component(Props(id))
  }

}
